package net.zoneland.knowledge.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import net.zoneland.knowledge.model.DirectTrainForParty;

/**
 * 党建服务直通车数据接口.
 * @author chw
 * @Date 2022/11/3
 */
@Mapper
public interface DirectTrainForPartyMapper {
    /**
     * 查询党建服务直通车.
     * @return 党建服务直通车集合
     */
    @Select({
        "SELECT ID, NUMBER_OF_PERIODS, TITLE, DATA_TIME, LINK_PC, LINK_MOA, VALID, DATA_TYPE, CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED ",
        "CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED ",
        "FROM AITK_DIRECT_TRAIN_FOR_PARTY WHERE VALID = 0 ",
    })
    @Results(id = "directTrainResultMap", value = {
        @Result(column="ID", property="id", jdbcType= JdbcType.VARCHAR, id=true),
        @Result(column="NUMBER_OF_PERIODS", property="numberOfPeriods", jdbcType=JdbcType.INTEGER),
        @Result(column="TITLE", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="DATA_TIME", property="dataTime", jdbcType=JdbcType.DATE),
        @Result(column="LINK_PC", property="linkPc", jdbcType=JdbcType.VARCHAR),
        @Result(column="LINK_MOA", property="linkMoa", jdbcType=JdbcType.VARCHAR),
        @Result(column="VALID", property="valid", jdbcType=JdbcType.INTEGER),
        @Result(column="DATA_TYPE", property="dataType", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATOR_USER_ID", property="creatorUserId", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATOR_USER_NAME", property="creatorUserName", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TIME", property="crateTime", jdbcType=JdbcType.DATE),
        @Result(column="LASTMODIFIED", property="lastModified", jdbcType=JdbcType.DATE),
        @Result(column="LIVE_CONTENT", property="liveContent", jdbcType=JdbcType.VARCHAR),
        @Result(column="VIDEO_LINK_ADDRESS", property="videoLinkAddress", jdbcType=JdbcType.VARCHAR),
    })
    List<DirectTrainForParty> search();

    /**
     * 查询pc端链接不为空的直通车数据.
     * @return 党组织集合
     */
    @Select({
        "SELECT ID, NUMBER_OF_PERIODS, TITLE, DATA_TIME, LINK_PC, LINK_MOA, VALID, DATA_TYPE, CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED ",
        "CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED, LIVE_CONTENT, VIDEO_LINK_ADDRESS ",
        "FROM AITK_DIRECT_TRAIN_FOR_PARTY WHERE VALID = 0 AND LINK_PC IS NOT NULL ORDER BY NUMBER_OF_PERIODS DESC",
    })
    @ResultMap(value = {"directTrainResultMap"})
    List<DirectTrainForParty> searchPc();

    /**
     * 查询moa端链接不为空的直通车数据.
     * @return 党组织集合
     */
    @Select({
        "SELECT ID, NUMBER_OF_PERIODS, TITLE, DATA_TIME, LINK_PC, LINK_MOA, VALID, DATA_TYPE, CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED ",
        "CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED ",
        "FROM AITK_DIRECT_TRAIN_FOR_PARTY WHERE VALID = 0 AND LINK_MOA IS NOT NULL ORDER BY NUMBER_OF_PERIODS DESC",
    })
    @ResultMap(value = {"directTrainResultMap"})
    List<DirectTrainForParty> searchMoa();

    /**
     * 根据title模糊查询党建直通车数据.
     * @return 直通车集合
     */
    @Select({
            "SELECT ID, NUMBER_OF_PERIODS, TITLE, DATA_TIME, LINK_PC, LINK_MOA, VALID, DATA_TYPE, CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED ",
            "CREATOR_USER_ID, CREATOR_USER_NAME, CREATE_TIME, LASTMODIFIED, LIVE_CONTENT, VIDEO_LINK_ADDRESS ",
            "FROM AITK_DIRECT_TRAIN_FOR_PARTY WHERE VALID = 0 AND LINK_PC IS NOT NULL and TITLE LIKE '%${title}%' ",
            "ORDER BY NUMBER_OF_PERIODS DESC",
    })
    @ResultMap(value = {"directTrainResultMap"})
    List<DirectTrainForParty> searchByTitle(String title);

}
